package com.youkeda.test.http;

import java.io.FileReader;
import java.io.IOException;

/**
 * 读文件工具类
 *
 * @author xshuai
 */
public class ReadFileTool {

    /**
     * 读取指定文件的内容
     */
    public static String readContent(String fileName) {
        FileReader fr = null;
        StringBuilder strBuilder = new StringBuilder();
        try {
            fr = new FileReader(fileName);
            int ch = 0;
            while ((ch = fr.read()) != -1) {
                strBuilder.append((char) ch);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (fr != null) {
                    fr.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return strBuilder.toString();
    }
}
